<?php
Class Engine_View_Helper_Bootstrap {

    public static function menuTiles( array $menuItems){
        $result = '';
        foreach ($menuItems as $item){
            $result .='<a class="tile wide app" href="' . $item['href'] . '">';
            $result .='<div class="image-wrapper">';
            $result .='<span class="fs1 main-tile" data-icon="' . $item['icon'] . '" aria-hidden="true"></span>';
            $result .= '</div>';
            $result .= '<div class="app-label">' . $item['name'] . '</div>';
            $result .= '<div class="app-count"></div>';
            $result .= '</a>';
        }
        echo $result;
    }

    public static function menuDropdown ($header, array $menuItems) {

            $result = '';
            $result .='<div class="dropdown"><a class="header-dropdown dropdown-toggle accent-color" data-toggle="dropdown" href="' . $menuItems[0]['href'] . '">';
            $result .= $header;
            $result .='<b class="caret"></b>';
            $result .='</a>';
            $result .='<ul class="dropdown-menu">';
                foreach ($menuItems as $item){
                    $result .='<li><a href="' . $item['href'] . '">' . $item['name'] . '</a></li>';
                }
            $result .='</ul>';
            $result .='</div>';
            echo $result;
    }

    public static function userInfo($user = null ){

        if (!$user) $user = Application_Bootstrap::getActiveUser();
        $result = '';
        $result .= '<div id="top-info" class="pull-right">';
        $result .= '<a href="#" class="pull-left">';
        $result .= '<div class="top-info-block">';
        $result .= '<h3>' . $user->firstname . ' ' . $user->lastname . '</h3>';
        $result .= '<h4>' . $user->role . '</h4>';
        $result .= '</div>';
        $result .= '<div class="top-info-block">';
        $result .= '<b class="icon-user"></b>';
        $result .= '</div>';
        $result .= '</a>';
        $result .= '<hr class="separator pull-left">';
        $result .= '<a id="settings" class="pull-left" href="/account/user/logout/">';
        $result .= '<b class="fs1" aria-hidden="true" data-icon="m"></b>';
        $result .= '</a>';
        $result .= '</div>';

        echo $result;
    }

    public static function error($error) {
        $result = '';
        if (!empty($error)) {
            if (!is_array($error)) $error[] = $error;
            $result .= "<div class=\"alert alert-error\">";
            foreach ($error as $err) {
                $result .= " <i class=\"icon-warning-sign\"></i> &nbsp; " . $err . "<br>";
            }
            $result .= "</div>";
        }
        return $result;
    }
}